package Demo2;
class MyValues{
   public int val;
}
public class Test {
    public static void main(String[] args) {
        MyValues myValues1=new MyValues();
        MyValues myValues2=new MyValues();
        myValues1.val=10;
        myValues2.val=20;
        System.out.println("交换前：");
        System.out.println(myValues1.val+" "+myValues2.val);
        swap2(myValues1,myValues2);
        System.out.println("交换后：");
        System.out.println(myValues1.val+" "+myValues2.val);
    }
    public static void swap2(MyValues m1,MyValues m2){
        int temp=m1.val;
        m1.val=m2.val;
        m2.val=temp;
    }
}
